using Castle.MonoRail.Framework;
using WineCellar.Data;
using WineCellar.Web.Controllers;

namespace WineCellar.Web.Components
{
    public class TableRowComponent :ViewComponent
    {
        public override void Render()
        {           
            if (EngineContext.CurrentController.GetType() == typeof(CellarController))
            {
                PropertyBag["cellar"] = ComponentParams["updatedObject"] as Cellar;                         
            }
			else if (EngineContext.CurrentController.GetType() == typeof(WinesController))
            {
                PropertyBag["wine"] = ComponentParams["updatedObject"] as Wine; 
            }
			else if (EngineContext.CurrentController.GetType() == typeof(RegionController))
            {
                PropertyBag["region"] = ComponentParams["updatedObject"] as Region; 
            }
			else if (EngineContext.CurrentController.GetType() == typeof(RaisinController))
            {
                PropertyBag["raisin"] = ComponentParams["updatedObject"] as Raisin;
            }
			else if (EngineContext.CurrentController.GetType() == typeof(CellarWinesController))
            {
                PropertyBag["cellarwine"] = ComponentParams["updatedObject"] as CellarWine;
            }
            base.Render();
        }
    }
}
